package com.share.utils;

import cn.hutool.jwt.JWT;

import java.nio.charset.StandardCharsets;


import static com.share.constant.DefaultConstant.*;
import static com.share.constant.DefaultConstant.TOKEN_EXPIRE_DATE;

public class JWTUtil {

    public static String generateToken(Long id) {
       return JWT.create()
                .setPayload(USERNAME_ID, id)
                .setPayload(LOGIN_TIME_KEY, System.currentTimeMillis())
                .setKey(JWT_KEY.getBytes(StandardCharsets.UTF_8))
                .setExpiresAt(TOKEN_EXPIRE_DATE)
                .sign();
    }
}
